<template>
    <div>
        <Card :bordered="false">
            <p slot="title">菜单权限</p>
            <tree :data="data" show-checkbox @on-check-change="getMenus"></tree>
        </Card>
    </div>
</template>
<script>
  export default {
    props: {
      role: String,
      data: Array
    },
    data() {
      return {}
    },
    methods: {
      getMenus(val) {
        let menuList = [];
        let accessCodes = [];
        val.forEach((item) => {
          if (item['children']) {
            return
          } else {
            menuList.push({
              menuName: item.title,
              serialNumber: item.key
            });
            accessCodes.push(item.key)
          }
        });
        this.$emit('getCurrentRoleRoot', accessCodes,menuList);
      }
    },
    mounted() {
    }
  }
</script>